<template>
  <div class="advice">
    <div :class="noData" v-if="emptyData">
      <img :src="img" alt="" />
      <span>暂无数据</span>
    </div>
    <div class="content" v-if="haveData">
      <div class="title_">
        <span>医嘱</span>
      </div>
      <div class="adviceContent">
        <div>
          <span class="title">护士执行时间：</span>
          <span class="content_">{{adviceData.authopertime}}</span>
        </div>
        <div>
          <span class="title">起始日期及时间：</span>
          <span class="content_">{{adviceData.chkopertime}}</span>
        </div>
        <div>
          <span class="title">频率间隔：</span>
          <span class="content_">{{adviceData.days}}</span>
        </div>
        <div>
          <span class="title">停止日期及时间：</span>
          <span class="content_">{{adviceData.endopertime}}</span>
        </div>
        <div>
          <span class="title">药品一次使用剂量：</span>
          <span class="content_">{{adviceData.dosage}}</span>
        </div>
        <div>
          <span class="title">病人本次住院标识：</span>
          <span class="content_">{{adviceData.hospid}}</span>
        </div>
        <div>
          <span class="title">医嘱序号：</span>
          <span class="content_">{{adviceData.id}}</span>
        </div>
        <div>
          <span class="title">医嘱代码：</span>
          <span class="content_">{{adviceData.itemid}}</span>
        </div>
        <div>
          <span class="title">医嘱正文：</span>
          <span class="content_">{{adviceData.name}}</span>
        </div>
        <div>
          <span class="title">病人标识号：</span>
          <span class="content_">{{adviceData.patid}}</span>
        </div>
        <div>
          <span class="title">执行频率描述：</span>
          <span class="content_">{{adviceData.printname}}</span>
        </div>
        <div>
          <span class="title">医嘱类别：</span>
          <span class="content_">{{adviceData.receipeclass}}</span>
        </div>
        <div>
          <span class="title">频率次数：</span>
          <span class="content_">{{adviceData.times}}</span>
        </div>
        <div>
          <span class="title">剂量单位：</span>
          <span class="content_">{{adviceData.unittakename}}</span>
        </div>
        <div>
          <span class="title">给药途径和方法：</span>
          <span class="content_">{{adviceData.usagename}}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import api from '../../../api/synthesis/synthesis.js'
import moment from "moment";
export default {
  name: "advice",
  props: {
    filter: String,
  },
  watch: {
    filter: {
      handler(val, oldVal) {
      },
      deep: true,
      immediate: true,
    },
  },
  data() {
    return {
      img: require("../../../../images/Synthesis/icon-NoData.png"),
      noData:'noData',
      emptyData:true,
      haveData:false,
      adviceData:{},
    };
  },
  mounted(){
    let _this = this;
    this.getReceipeInfo()
    window.Event.$on("menuLeft", val => {
      _this.menuLeft = val;
      if (_this.menuLeft != "menuDeaDolour") {
        _this.img = require("../../../../images/Synthesis/icon-NoData.png");
        _this.noData='noData';
      } else if (_this.menuLeft == "menuDeaDolour") {
        _this.img = require("../../../../images/Synthesis/icon-NoData1.png");
        _this.noData='noData1';
      }
    });
    // _this.menuLeft1 = _this.$store.state.menuLeft;
    _this.menuLeft1 = sessionStorage.getItem('menuLeft')
    if (_this.menuLeft1 != "menuDeaDolour") {
      _this.img = require("../../../../images/Synthesis/icon-NoData.png");
      _this.noData='noData';
    } else if (_this.menuLeft1 == "menuDeaDolour") {
      _this.img = require("../../../../images/Synthesis/icon-NoData1.png");
      _this.noData='noData1';
    }
  },
  methods: {
    getReceipeInfo(){
      let _this = this;
      api.getReceipeInfo(null,{filter:_this.filter}).then(res=>{
        if(res.data != null) {
          _this.emptyData = false;
          _this.haveData = true;
          if(res.code == 200) {
            _this.adviceData = res.data
            _this.adviceData.authopertime = moment(_this.adviceData.authopertime).format("YYYY-MM-DD HH:mm:ss");
            _this.adviceData.chkopertime = moment(_this.adviceData.chkopertime).format("YYYY-MM-DD HH:mm:ss");
            _this.adviceData.endopertime = moment(_this.adviceData.endopertime).format("YYYY-MM-DD HH:mm:ss");
          }
        }else if(res.data == null) {
          _this.emptyData = true;
          _this.haveData = false;
        }
      })
    },
  },
};
</script>

<style lang="scss" scoped>
.advice {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  .noData {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: absolute;
    left: 50%;
    z-index: 10;
    img {
      width: 75px;
      height: 95px;
    }
    span {
      font-size: 16px;
      color: #0078b6;
      line-height: 40px;
    }
  }
  .noData1 {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: absolute;
    left: 50%;
    z-index: 10;
    img {
      width: 75px;
      height: 95px;
    }
    span {
      font-size: 16px;
      color: #73777a;
      line-height: 40px;
    }
  }
  .content {
    position: absolute;
    width: 90%;
    min-height: 700px;
    top: 30px;
    left: 30px;
    background: #fff;
    border-radius: 8px;
    .title_ {
      width: 100%;
      height: 50px;
      display: flex;
      align-items: center;
      border-bottom: 1px #ddd solid;
      span {
        margin-left: 30px;
        font-size: 16px;
        font-weight: bold;
      }
    }
    .adviceContent {
      width: 70%;
      height: 100%;
      display: flex;
      flex-wrap: wrap;
      .title {
        width: 50%;
      }
      div {
        width: 50%;
        padding: 20px 50px;
        display: flex;
        span {
          width: 30%;
          display: flex;
          font-size: 16px;
        }
        .content_ {
          width: 70%;
        }
      }
    }
  }
}
</style>

<style>
</style>